package com.pactera.config;

import java.util.Properties;

import org.springframework.boot.autoconfigure.web.ErrorProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.github.pagehelper.PageHelper;

/**
 * mvc配置类
 * @author lee
 */
@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter {
	
	@Bean
    public ErrorProperties errorProperties(){
        return new ErrorProperties();
    }
	
	//配置mybatis的分页插件pageHelper
    @Bean
    public PageHelper pageHelper(){
        PageHelper pageHelper = new PageHelper();
        Properties properties = new Properties();
        properties.setProperty("offsetAsPageNum","true");
        properties.setProperty("rowBoundsWithCount","true");
        properties.setProperty("reasonable","true");
//        properties.setProperty("dialect","mysql");//配置mysql数据库的方言    
        properties.setProperty("autoRuntimeDialect","true");//根据数据源动态切换方言
        pageHelper.setProperties(properties);
        return pageHelper;
    }
}
